project(Demo)

set(QT_CPP_ROOTDIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_PREFIX_PATH "${QT_CPP_ROOTDIR}/3rdParty/qt")
set(Qt5_DIR "${QT_CPP_ROOTDIR}/3rdParty/qt/lib/cmake/lib")
set(CMAKE_AUTOMOC ON)

find_package(Qt5 COMPONENTS Widgets Core Gui Multimedia MultimediaWidgets Network REQUIRED)

set(WEBKIT_ZIP "${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/qt/bin/Qt5WebKit.rar")
set(WEBKIT_DLL "${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/qt/bin/Qt5WebKit.dll")
set(DESTINATION_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/qt/bin/")

if(NOT EXISTS ${WEBKIT_DLL})
    message(STATUS "unzip ${WEBKIT_ZIP} 到 ${DESTINATION_DIR}")
    execute_process(
        COMMAND ${CMAKE_COMMAND} -E tar xf ${WEBKIT_ZIP}
        WORKING_DIRECTORY ${DESTINATION_DIR}
    )
endif()


set(PLUGIN_DIR "${QT_CPP_ROOTDIR}/3rdParty/qt/plugins")
file(GLOB PLUGIN_SUBDIRECTORIES RELATIVE "${PLUGIN_DIR}" "${PLUGIN_DIR}/*")
foreach(subdirectory ${PLUGIN_SUBDIRECTORIES})
    file(COPY "${PLUGIN_DIR}/${subdirectory}" DESTINATION "${CMAKE_BINARY_DIR}/bin/")
endforeach()

add_subdirectory(code)

